#include <iostream>
#include <unistd.h>
#include "task.hpp"
#include "threadPool.hpp"

void test()
{
    printf("%p\n", xyl::ThreadPool<Task>::get_instance());
}

int main()
{
    // xyl::ThreadPool<Task> *tp = new xyl::ThreadPool<Task>();
    xyl::ThreadPool<Task> *tp = xyl::ThreadPool<Task>::get_instance();
    xyl::ThreadPool<Task> * tmp = tp->get_instance();
    printf("%p\n", tp);
    printf("%p\n", tmp);

    test();
    
    sleep(2);
    int cnt = 2;
    while (cnt--)
    {
        tp->push_task(Task(2, 4, '*'));
        sleep(1);
        tp->push_task(Task(2, 5, '*'));
        sleep(1);
        tp->push_task(Task(2, 4, '/'));
        sleep(1);
        tp->push_task(Task(2, 4, '%'));
        sleep(1);
        tp->push_task(Task(6, 4, '*'));
        sleep(1);
        tp->push_task(Task(2, 0, '/'));
        sleep(1);
        tp->push_task(Task(2, 4, '+'));
        sleep(1);
    }
    delete tp;
    return 0;
}